//
//  GYMyBuyProductDetailViewModel.m
//  GYDemo
//
//  Created by Mrzhang on 2018/4/8.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYMyBuyProductDetailViewModel.h"
#import "Head.h"
@implementation MyBuyProductDetailInfoModel
//+ (NSDictionary *)modelCustomPropertyMapper {
//    return @{
//             @"descriptionField":@"description"
//             };
//}
@end
@implementation MyBuyProductUserInfoModel
@end
@implementation MyBuyProductProtypeInfoModel
@end
@implementation GoodSCommentModel
@end


@implementation GYMyBuyProductDetailViewModel
#pragma mark setter getter
-(NSMutableArray *)protypeArr
{
    if (!_protypeArr) {
        _protypeArr=[[NSMutableArray alloc] init];
    }
    return _protypeArr;
}
-(NSMutableArray *)RecordArr
{
    if (!_RecordArr) {
        _RecordArr=[[NSMutableArray alloc] init];
    }
    return _RecordArr;
}

-(MyBuyProductUserInfoModel *)BuyProductUserInfoModel
{
    if (!_BuyProductUserInfoModel) {
        _BuyProductUserInfoModel=[[MyBuyProductUserInfoModel alloc] init];
    }
    return _BuyProductUserInfoModel;
}
-(MyBuyProductDetailInfoModel *)BuyProductDetailInfoModel
{
    if (!_BuyProductDetailInfoModel) {
        _BuyProductDetailInfoModel=[[MyBuyProductDetailInfoModel alloc] init];
    }
    return _BuyProductDetailInfoModel;
}
-(instancetype)init
{
    if (self = [super init]) {
        //添加接口特殊处理
        [[InterfaceManager shareInterface].specialInterfaces addObject:@"buyDealRecord"];
        [[InterfaceManager shareInterface].specialInterfaces addObject:@"goodsCommentList"];
        
        
    }
    return self;
}
//详情
-(void)requestInfo:(NSMutableDictionary *)para
{
    @WeakSelf;
    NSString *interface = @"UVTGetGoodDetail";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        NSDictionary *data = infoModel.data;
        NSArray* myArr=(NSArray*)info;
        if (myArr.count>0) {
            MyBuyProductDetailInfoModel *model = [MyBuyProductDetailInfoModel yy_modelWithJSON:myArr[0]];
            [selfp setBuyProductDetailInfoModel:model];
        }
    }];
}
//记录
-(void)requestRecord:(NSMutableDictionary *)para
{
    //buyDealRecord
    @WeakSelf;
    NSString *interface = @"goodsCommentList";

   // NSString *page = para[@"page"];
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        NSDictionary *data = infoModel.data;
        if ([data isKindOfClass:[NSDictionary class]]) {
            NSArray *datalist = data[@"datalist"];
        
            if ([datalist isKindOfClass:[NSArray class]]) {
                NSMutableArray *arr=[NSMutableArray new];
                
                for (NSDictionary *dic in datalist) {
                    GoodSCommentModel *model = [GoodSCommentModel yy_modelWithJSON:dic];
                    [arr addObject:model];
                }
                [selfp setRecordArr:arr];
            }

        }
        
//        if ([data isKindOfClass:[NSDictionary class]]) {
//            NSArray *datalist = data[@"datalist"];
//
//            if ([datalist count]<10) {
//                selfp.canAddMore=NO;
//            }else
//            {
//                selfp.canAddMore=YES;
//            }
//            if ([datalist isKindOfClass:[NSArray class]]) {
//                NSMutableArray *arr;
//                if ([page isEqualToString:@"1"]) {
//                    arr = [NSMutableArray new];
//                }else{
//                    arr = self.RecordArr;
//                }
//                for (NSDictionary *dic in datalist) {
//                    MyBuyProductProtypeInfoModel *model = [MyBuyProductProtypeInfoModel yy_modelWithJSON:dic];
//                    [arr addObject:model];
//                }
//                [selfp setRecordArr:arr];
//            }
//        }else
//        {
//            selfp.canAddMore=NO;
//            if ([page isEqualToString:@"1"])
//            {
//                NSMutableArray *arr;
//                [selfp setRecordArr:arr];
//            }
//
//        }
    }];
}


//购物车
-(void)requestPut:(NSMutableDictionary *)para
{
    
    NSString *interface = @"joinShoppingCar";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        NSDictionary *data = infoModel.data;
        [FTIndicator showSuccessWithMessage:@"成功加入购物车"];
        if ([data isKindOfClass:[NSDictionary class]]) {

        }
    }];
}
@end
